﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Zero.Core;
using Zero.Entity.Models;
using Zero.Service;
using Zero.Core.Extensions;

namespace Zero.Web.Controllers
{
    public class HomeController : BaseController
    {
        private readonly ISystemService systemService;
        public HomeController(ISystemService systemService)
        {
            this.systemService = systemService;
        }
        //
        // GET: /Home/
        
        public ActionResult Index()
        {
            string strUserID = SysContext.CurrentUserID;
            List<Sys_Menu> Menus = systemService.GetUserMenus(strUserID).Where(m => m.MenuParentID.ToStr() == "00000000-0000-0000-0000-000000000000").ToList();
            return View(Menus);
        }

        //
        // GET: /Home/Details/5

        public ActionResult Details(int id)
        {
            return  View();
        }

        //
        // GET: /Home/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Home/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Home/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Home/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Home/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Home/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
